﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using Common.Utilities.Dispatcher;
using Common.Utilities.DLR;

namespace Workflows.Components.Rules
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    [OrmClass("Rules", "RuleID", false)]
    public class Rule
    {
        #region fields & props
        private Guid _RuleID;
        /// <summary></summary>
        public Guid RuleID
        {
            get
            {
                return this._RuleID;
            }
            set
            {
                this._RuleID = value;
            }
        }
        private string _RuleName;
        /// <summary></summary>
        public string RuleName
        {
            get
            {
                return this._RuleName;
            }
            set
            {
                this._RuleName = value;
            }
        }
        private string _RuleCategory;
        /// <summary></summary>
        public string RuleCategory
        {
            get
            {
                return this._RuleCategory;
            }
            set
            {
                this._RuleCategory = value;
            }
        }
        private string _CreatedBy;
        /// <summary></summary>
        public string CreatedBy
        {
            get
            {
                return this._CreatedBy;
            }
            set
            {
                this._CreatedBy = value;
            }
        }
        private DateTime _CreatedOn;
        /// <summary></summary>
        public DateTime CreatedOn
        {
            get
            {
                return this._CreatedOn;
            }
            set
            {
                this._CreatedOn = value;
            }
        }
        private string _AssemblyFilePath;
        /// <summary></summary>
        public string AssemblyFilePath
        {
            get
            {
                return this._AssemblyFilePath;
            }
            set
            {
                this._AssemblyFilePath = value;
            }
        }
        private string _BusinessObjectName;
        /// <summary></summary>
        public string BusinessObjectName
        {
            get
            {
                return this._BusinessObjectName;
            }
            set
            {
                this._BusinessObjectName = value;
            }
        }
        private GlobalVariable[] _Vars;
        /// <summary></summary>
        [OrmField("Vars", SqlDbType.Text, 4000, OrmFieldSerializationMethod.BinarySerialization)]
        public GlobalVariable[] Vars
        {
            get
            {
                return this._Vars;
            }
            set
            {
                this._Vars = value;
            }
        }
        private RuleNodeDataBase[] _RuleNodes;
        /// <summary></summary>
        [OrmField("RuleNodes", SqlDbType.Text, 4000, OrmFieldSerializationMethod.BinarySerialization)]
        public RuleNodeDataBase[] RuleNodes
        {
            get
            {
                return this._RuleNodes;
            }
            set
            {
                this._RuleNodes = value;
            }
        }

        private RuleInitializer _Start;
        /// <summary></summary>
        [OrmField("Start",SqlDbType.Text,4000,OrmFieldSerializationMethod.BinarySerialization)]
        public RuleInitializer Start
        {
            get
            {
                return this._Start;
            }
            set
            {
                this._Start = value;
            }
        }

        private RuleFinalizer _Finish;
        /// <summary></summary>
        [OrmField("Finish", SqlDbType.Text, 4000, OrmFieldSerializationMethod.BinarySerialization)]
        public RuleFinalizer Finish
        {
            get
            {
                return this._Finish;
            }
            set
            {
                this._Finish = value;
            }
        }

        private string _RuleDesignFilePath;
        /// <summary></summary>
        public string RuleDesignFilePath
        {
            get
            {
                return this._RuleDesignFilePath;
            }
            set
            {
                this._RuleDesignFilePath = value;
            }
        }
        private string _Description;
        /// <summary></summary>
        public string Description
        {
            get
            {
                return this._Description;
            }
            set
            {
                this._Description = value;
            }
        }
        #endregion

        #region ctor
        /// <summary>
        /// 
        /// </summary>
        public Rule()
        {
            this._RuleID = Guid.NewGuid();
            this._RuleName = "New Rule";
            this._RuleCategory = "Simple rules";
            this._AssemblyFilePath = string.Empty;
            this._BusinessObjectName = string.Empty;
            this._CreatedBy = Environment.UserName;
            this._CreatedOn = DateTime.Now;
            this._Vars = null;
            this._Start = null;
            this._Finish = null;
            this._RuleNodes = null;
            this._RuleDesignFilePath = string.Empty;
            this._Description = string.Empty;
        }
        #endregion
    }
}
